-
Notifications
You must be signed in to change notification settings - Fork 5.7k
[JEWEL-1024] Improvements to SpeedSearchArea to support using for filter #3361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
9ed15c7 to
8857fc4
Compare
...jewel/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/lazy/SelectableLazyColumn.kt
Outdated
Show resolved
Hide resolved
...ewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/search/SpeedSearchableLazyColumn.kt
Show resolved
Hide resolved
dc7354c to
f2d590a
Compare
wellingtoncosta
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just small suggestions, LGTM overall.
...jewel/foundation/src/test/kotlin/org/jetbrains/jewel/foundation/search/IterableFilterTest.kt
Outdated
Show resolved
Hide resolved
...jewel/foundation/src/test/kotlin/org/jetbrains/jewel/foundation/search/IterableFilterTest.kt
Outdated
Show resolved
Hide resolved
f2d590a to
d541a52
Compare
platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/SpeedSearchArea.kt
Show resolved
Hide resolved
d541a52 to
953694e
Compare
|
FYI, I've added a warning banner to the new screen mentioning that the speed search component is not intended to this behavior. I'm also working on JEWEL-849, but it is taking a bit longer than I expected.
|
platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/SpeedSearchArea.kt
Outdated
Show resolved
Hide resolved
...jewel/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/search/SpeedSearchMatcher.kt
Outdated
Show resolved
Hide resolved
...jewel/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/search/SpeedSearchMatcher.kt
Outdated
Show resolved
Hide resolved
...jewel/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/search/SpeedSearchMatcher.kt
Outdated
Show resolved
Hide resolved
...s/showcase/src/main/kotlin/org/jetbrains/jewel/samples/showcase/views/ComponentsViewModel.kt
Outdated
Show resolved
Hide resolved
...ewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/search/SpeedSearchableLazyColumn.kt
Show resolved
Hide resolved
| @ExperimentalJewelApi | ||
| @ApiStatus.Experimental | ||
| @Deprecated("Kept for binary compatibility", level = DeprecationLevel.HIDDEN) | ||
| public fun SpeedSearchArea( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we haz KDoc plz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind this is hidden
platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/SpeedSearchArea.kt
Outdated
Show resolved
Hide resolved
953694e to
7d7b12b
Compare
- Fixed index emission on SelectableLazyColumn when the selection changes by the speed search - Created 'EmptySpeedSearchMatcher' to easily identify when the filter text is empty - This matches is automatically returned in the SpeedSearchState.matcher when the text is empty - Added 'dismissOnLoseFocus' to SpeedSearchArea to keep the filter when the focus is left from the component - Added 'currentMatcher' to the 'SpeedSearchState', allowing the user use it for filtering purposes - Created convenience function on top of 'SpeedSearchMatcher' to check if the given text matches or not - Created convenience functions to support filtering collections based on the speed search matcher
7d7b12b to
9bfb03a
Compare
| Snapshot.withMutableSnapshot { | ||
| textFieldState.edit { delete(0, length) } | ||
| searchText = "" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clearSearch doesn't reset currentMatcher causing stale filter state
Medium Severity
The clearSearch() method clears textFieldState and searchText within a Snapshot.withMutableSnapshot block but does not update currentMatcher to EmptySpeedSearchMatcher. The currentMatcher is only updated asynchronously by the flow running on a background dispatcher. This creates a race condition where consumers using currentMatcher for filtering (like derivedStateOf { list.filter(speedSearchState.currentMatcher) }) may see stale filter results after the search is cleared, causing a brief visual flicker where the list stays filtered even though the search input has disappeared.

Evidences
Release notes
New features
Bug fixes
Note
Introduces filtering-friendly SpeedSearch and related API updates, plus selection emission fixes and samples/tests.
EmptySpeedSearchMatcher,CharSequence.matches, andIterable.filter(...)helpers;SpeedSearchMatcher.matchesnow acceptsCharSequenceSpeedSearchArea: new overloads with externalSpeedSearchState,rememberSpeedSearchState, anddismissOnLoseFocusflag; exposesSpeedSearchState.currentMatcher,isVisiblesetter, and internaltextFieldState; batching + matcher caching for performanceSpeedSearchableLazyColumnscroll logic to sync with search/selection; wires attach flows; improves index sync when search is clearedSelectableLazyColumnto emitonSelectedIndexesChangewhen SpeedSearch changes selection and to resynclastActiveItemIndexSpeedSearches), icon, and comprehensive UI/tests (including filtering behavior and focus-dismiss cases)Written by Cursor Bugbot for commit 9bfb03a. This will update automatically on new commits. Configure here.